<%@include file="template/configuration.jsp" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>${website} || Manage pages</title>
        ${stylesheet}
        ${jquery}
    </head>
    <body>
        <div class="container">
            <%@include file="template/header.jsp" %>
            <div class="content">
                <h1>Manage pages</h1>
                <!-- clear //-->
                <div class="clear margin-bottom-10"></div>
                <div class="full-block">
                    <c:choose>
                        <c:when test="${fn:length(pages) > 0}">
                            <table class="overview">
                                <tr>
                                    <th>Title</th>
                                    <th>Content</th>
                                    <th class="single-icon">Manage</th>
                                </tr>
                                <c:set var="i" value="0"/>
                                <c:forEach items="${pages}" var="page">
                                    <c:set var="i" value="${i + 1}"/>
                                    <tr class="<c:choose><c:when test="${i % 2 == 0}">even</c:when><c:otherwise>odd</c:otherwise></c:choose>">
                                        <td>${page.title}</td>
                                        <td>
                                            <c:choose>
                                                <c:when test="${fn:length(page.content) > 80}">
                                                     <c:out value="${fn:substring(page.content, 0, 80)}"/>...
                                                </c:when>
                                                <c:otherwise>
                                                    <c:out value="${page.content}"/>
                                                </c:otherwise>
                                            </c:choose>
                                        </td>
                                        <td>
                                            <a href="${url}ManagePage?edit=${page.id}"><img src="${url}images/edit.png"/></a>
                                            <span class="info">page <strong>${page.title}</strong></span>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </table>
                        </c:when>
                        <c:otherwise>
                            There are no pages yet.
                        </c:otherwise>
                    </c:choose>
                </div>
            </div>
            <%@include file="template/footer.jsp" %>
        </div>
    </body>
</html>
